﻿<Window x:Class="Flipbook.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:Flipbook.Controls"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:InputInteractivity="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:Behaviors="clr-namespace:Flipbook.Behaviors"
        x:Name="WindowElement"
        Title="FlipBook"
        Icon="Images/AppIcon.ico"
        Background="DarkSalmon"
        Height="350"
        Width="525"
        WindowState="Maximized">
    <Grid x:Name="MainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Expander Grid.Row="0"
                  IsExpanded="True">
            <Controls:EditorRibbonControl Height="100" />
        </Expander>        
        <Grid x:Name="CanvasGrid"
              Grid.Row="1"
              Grid.Column="0">
            <ContentControl x:Name="BackCanvasContainer"
                            Content="{Binding Path=BackCanvasViewModel.Canvas}">
            </ContentControl>
            <ContentControl x:Name="CanvasContainer"
                            Content="{Binding Path=ActiveCanvasViewModel.Canvas}">
                <ContentControl.Resources>
                    <Style TargetType="{x:Type InkCanvas}">
                        <Setter Property="EditingMode"
                                Value="{Binding Path=DesignerProperties.EditingMode}" />
                    </Style>
                </ContentControl.Resources>
            </ContentControl>
            <i:Interaction.Behaviors>
                <Behaviors:ManipulationToCommandBehavior SupportedManipulations="Scale"
                                                         Command="{Binding ElementName=WindowElement, Path=ZoomOutCommand}" />
                <InputInteractivity:TranslateZoomRotateBehavior SupportedGestures="Rotate"
                                                                RotationalFriction=".5" />
                <Behaviors:GestureToCommandBehavior SupportedGestures="Tap"
                                                    Command="{Binding ElementName=WindowElement, Path=ResetRotationCommand}" />              
            </i:Interaction.Behaviors>
        </Grid>
        <Expander Grid.Row="2"
                  IsExpanded="True">
            <ListBox Height="110"
                     ItemsSource="{Binding CanvasViewModels}"
                     SelectedItem="{Binding ActiveCanvasViewModel}">                
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"
                                    IsItemsHost="True" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="0.25"
                                BorderBrush="Black"
                                Width="100"
                                Height="100">
                            <Border.Background>
                                <VisualBrush Visual="{Binding Canvas}" />
                            </Border.Background>
                            <i:Interaction.Behaviors>
                                <Behaviors:GestureToCommandBehavior SupportedGestures="Flick"
                                                                    Command="{Binding ElementName=WindowElement, Path=DisplayCanvasSubsetCommand}"
                                                                    CommandParameter="{Binding}"/>
                            </i:Interaction.Behaviors>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <i:Interaction.Behaviors>
                    <Behaviors:ListBoxItemReorderingBehavior/>
                </i:Interaction.Behaviors>
            </ListBox>
        </Expander>
        <Canvas Grid.Row="1"                          
                x:Name="Canvas"/>
    </Grid>
</Window>